-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dispenserSpawnEntity event (1.19.4) #10669
base: ver/1.19.4
Are you sure you want to change the base?
Conversation
I think a new event for that would be unnecessary |
Yes, i could do that, but i will only have access to exactly the item using that approach. And for what i want to do i need access to the entity created when dispensed and the dispenser itself. Correct me if i'm wrong, but ItemDispenseEvent only gives access to the item. And i would need to replicate the entire logic for entity spawning through dispensed items (e.g. eggs, tnt, arrow and so on) for it to be accurate. The other way that i'm aware of is using ASM or mixins or similar to achieve this or to use NMS and to re-register all the dispenseBehaviors with altered code. EDIT: Access to the dispenser is given in the ItemDispenseEvent. Yet that doesn't change anything about the jankiness of that solution. |
you could listen to the entity spawn event caused by dispensers |
Iirc there is just an entity spawn event, no? Haven't seen one specific for dispensers. And iirc the entity spawn event lacks a "reason" or context what spawned the entity or am i missing something here? |
i didn't look at the implementation of this so i am not sure if this is possible but perhaps you could expand on the BlockDispenseEvent by adding a getEntity or something similar EDIT: also you can just relocate the current pr to the master branch you don't to create a new one |
ok, that gets me the reason, but for what i want to do i need to have access to the dispenser too. And having to scan every of the 8/14 blocks around the entity is not an option |
Hm, good idea |
I think this duplicates a lot of what is proposed in #7377. |
Looks like it. Will still keep this open though, cause the PR you mentioned hasn't been touched in quite some time. EDIT: Wait, according to the description it doesn't fire when projectiles are being fired from dispensers? |
The idea of adding an entity to the existing dispense event is actually pretty good. |
The projectile source is on the Projectile entity with https://jd.papermc.io/paper/1.20.6/org/bukkit/projectiles/BlockProjectileSource.html. |
Interesting, i will take a look, thanks! |
Ok, took a look, I can use that for any projectile, but i still need something for the tnt being dispensed. I know of workarounds but using those is not an option. Guess I'll adjust my solution here and wait for the (probably unlikely) case that it will be merged. Otherwise I need to find a way to compile the jar on my own. |
Yes, the mentioned PR does add an event for handling TNT which can't have a projectile source as its not a projectile. |
Adds a cancellable event that gets fired whenever a dispenser would spawn a entity (mainly useful for projectiles and primed tnt).
Workarounds for this would involve cancelling the entire event per item stack which in my opinion is not the best solution. Another workaround would be to use ASM or similar to manually adjust the source code. Or one could use NMS to manually override the dispense behaviors, which would be more effort over all though.
EDIT: Realized i made this on the 1.19.4 branch, will make a new PR for the master one